package Ep01_Array.Feb24th_2357;

import java.util.Arrays;

/**
 * @author Jimmy Zhan WORKSTATION
 * @Date 2023/2/24 14:19
 * 说明：力扣每日 2357 —— 贪心
 * 找元素种类数，但是要小心空数组和 0元素数组
 */

public class Mine_2 {

    public static void main(String[] args) {
        int[] nums = {0};
        Mine_2 m2 = new Mine_2();
        System.out.println(m2.minimumOperations(nums));
    }

    public int minimumOperations(int[] nums){
        boolean isZero = true;
        for (int i = 0; i < nums.length; i++) {
            if (nums[i] != 0){
                isZero = false;
                break;
            }
        }
        if (nums.length == 0){
            return 0;
        } else if (isZero == true){
            return 0;
        } else {
            Arrays.sort(nums);
            int counter = 1;
            for (int i = 1; i < nums.length; i++) {
                if(nums[i] != nums[i-1] && nums[i-1] != 0){
                    counter++;
                }
            }
            return counter;
        }
    }
}
